﻿using B.Rabbit.DataBase.ErrorCode;
using B.Rabbit.DataBase.Read.Api.Applocation.Command.Login;
using B.Rabbit.DataBase.Read.Api.DTOs;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace B.Rabbit.DataBase.Read.Api.Controllers
{
    /// <summary>
    /// 登录控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LoginController : ControllerBase
    {
        IMediator mediator;
        public LoginController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<LoginDTOs>> Login(LoginCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }
    }
}
